// Standard Library:
#include <math.h>
#include <stdio.h>
#include <stdlib.h>

unsigned parse_uint(char* s)
{
	unsigned result;
	if (sscanf(s, "%u", &result) != 1)
	{
		fprintf(stderr, "Fehler: Der eingegebene Wert '%s' ist keine Zahl\n", s);
		exit(EXIT_FAILURE);
	}
	return result;
}

int is_prime(unsigned val)
{
	unsigned root = (unsigned)sqrt((float)val);
	for (unsigned i = 2; i < root; ++i)
	{
		if (val % i == 0)
			return 0;
	}
	return 1;
}

int main(int argc, char** argv)
{
	// Read input.
	if (argc != 2)
	{
		fprintf(stderr, "%s <Zahl>\n", argv[0]);
		return EXIT_FAILURE;
	}
	unsigned number = parse_uint(argv[1]);

	unsigned i = 2;
	unsigned lastFactor = 0, lastCount = 0;
	while (number > 1)
	{
		if (number % i == 0 && is_prime(i))
		{
			number /= i;

			if (i != lastFactor)
			{
				if (lastFactor != 0)
					printf("%d^%d * ", lastFactor, lastCount);
				lastFactor = i;
				lastCount = 1;
			}
			else
			{
				++lastCount;
			}
		}
		else
		{
			++i;
		}
	}
	printf("%d^%d", lastFactor, lastCount);
}

